package com.fan.txl.di.module;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.f2prateek.rx.preferences2.RxSharedPreferences;
import com.fan.txl.pay.Pay;
import com.fan.txl.pay.PayInterface;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by janisharali on 25/12/16.
 */

@Module
public class ApplicationModule {

    private  Application mApplication;

    public ApplicationModule(Application app) {
        mApplication = app;
    }


    @Provides
    public Application provideApplication() {
        return mApplication;
    }

    @Provides
    public RxSharedPreferences provideRxSharedPreferences(SharedPreferences sharedPreferences) {
        return RxSharedPreferences.create(sharedPreferences);
    }

    @Provides
    public SharedPreferences provideSharedPreferences() {
       return PreferenceManager.getDefaultSharedPreferences(mApplication);
    }

    @Provides
    public IWXAPI provideIWXAPI(@Named("wx")String appid) {
        IWXAPI api = WXAPIFactory.createWXAPI(mApplication,appid);
        //api.registerApp(appid)
        return api;
    }

    @Provides
    public PayInterface providePayInterface() {
        return new Pay();
    }


    @Provides
    @Named("wx")
    String  provideswxid() {
        return    "wx0a4b42b6f7950b18";
    }


}
